Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: LSM changes to distribution #4

Merged
merged 10 commits into from
Nov 28, 2023
Merged

Conversation

mpoke
Copy link
Collaborator

@mpoke mpoke commented Nov 27, 2023

Description

Related: cosmos#18200

Port the LSM changes to the distribution module to 0.47. Also, add the staking changes necessary to deal with errors.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

DefaultWeightMsgFundCommunityPool int = 50
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" //nolint:gosec

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
DefaultWeightMsgWithdrawValidatorCommission int = 50
DefaultWeightMsgFundCommunityPool int = 50
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
DefaultWeightMsgWithdrawDelegationReward int = 50
DefaultWeightMsgWithdrawValidatorCommission int = 50
DefaultWeightMsgFundCommunityPool int = 50
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" //nolint:gosec
OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool" //nolint:gosec
OpWeightMsgWithdrawAllTokenizeShareRecordReward = "op_weight_msg_withdraw_all_tokenize_share_record_reward" //nolint:gosec

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" //nolint:gosec
OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool" //nolint:gosec

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
func (msg MsgWithdrawTokenizeShareRecordReward) GetSigners() []sdk.AccAddress {
owner, err := sdk.AccAddressFromBech32(msg.OwnerAddress)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
func (msg MsgWithdrawAllTokenizeShareRecordReward) GetSigners() []sdk.AccAddress {
owner, err := sdk.AccAddressFromBech32(msg.OwnerAddress)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@sainoe
Copy link

sainoe commented Nov 28, 2023

Could please add BeforeTokenizeShareRecordRemoved to the hook methods of the distribution module?

@mpoke
Copy link
Collaborator Author

mpoke commented Nov 28, 2023

Could please add BeforeTokenizeShareRecordRemoved to the hook methods of the distribution module?

Nice catch

@sainoe
Copy link

sainoe commented Nov 28, 2023

Okay for merging

@@ -98,6 +98,10 @@ func TestCalculateRewardsBasic(t *testing.T) {
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: math.LegacyNewDec(initial / 2)}}, distrKeeper.GetValidatorAccumulatedCommission(ctx, valAddr).Commission)
}

func TestWithdrawTokenizeShareRecordReward(t *testing.T) {
// TODO add LSM test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge without this test as I will add it a little later.

Copy link

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Missing tests will be added in subsequent PRs.

@mpoke mpoke merged commit 16938f1 into feat/lsm/v0.47.x Nov 28, 2023
15 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants